package collection.map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

public class MapExample {
	HashMap<Integer, String> hmap;
	TreeMap<Integer, String> tmap;
	
	public MapExample() {
		hmap = new HashMap<>();
		tmap = new TreeMap<>();
		addData();
	}

	private void addData() {
		hmap.put(21, "twenty one");
		hmap.put(10, "ten");
		hmap.put(69, "sixty nine");

		tmap.putAll(hmap);
	}
	
	public void display(Map<Integer, String> map){
		Iterator<Integer> iter = map.keySet().iterator();
		while (iter.hasNext()) {
			int key = iter.next();
			System.out.println(key + " -> " + map.get(key));
		}
		System.out.println();
	}

	public static void main(String[] args) {
		MapExample ex = new MapExample();
		ex.display(ex.hmap);

		ex.display(ex.tmap);
	}
	
}
